﻿namespace TomatoBreak.Web
{
    using System.Web.Mvc;
    using System.ComponentModel.DataAnnotations;

    public class CreateUserModel
    {
        [Required(ErrorMessageResourceName = "UserNameRequired", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [StringLength(32, MinimumLength = 4, ErrorMessageResourceName = "UserNameLength", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [RegularExpression(@"^([a-zA-Z0-9_\-])*$", ErrorMessageResourceName = "UserNamePattern", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [Display(Name = "User name")]
        public string UserName { get; set; }

        [Required(ErrorMessageResourceName = "PasswordRequired", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [StringLength(64, MinimumLength = 6, ErrorMessageResourceName = "PasswordLength", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [DataType(DataType.Password)]
        public string Password { get; set; }

        [Required(ErrorMessageResourceName = "ConfirmPasswordRequired", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [Compare("Password", ErrorMessageResourceName = "ConfirmPasswordMatch", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [DataType(DataType.Password)]
        public string Confirm { get; set; }

        [Required(ErrorMessageResourceName = "EmailRequired", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [StringLength(256, ErrorMessageResourceName = "EmailLength", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [RegularExpression(@"^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", ErrorMessageResourceName = "EmailPattern", ErrorMessageResourceType = typeof(ModelValidationMessages))]
        [DataType(DataType.EmailAddress)]
        public string Email { get; set; }
    }
}